
package org.apache.solr.response.transform;

import java.util.Set;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.FieldType;
import org.apache.solr.schema.SchemaField;

/**
 * Used to mark whether a document has been elevated or not
 *
 * @since solr 4.0
 */
public class ElevatedMarkerFactory extends TransformerFactory {

    @Override
    public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) {
        SchemaField uniqueKeyField = req.getSchema().getUniqueKeyField();
        String idfield = uniqueKeyField.getName();
        return new MarkTransformer(field, idfield, uniqueKeyField.getType());
    }
}

class MarkTransformer extends BaseEditorialTransformer {

    MarkTransformer(String name, String idFieldName, FieldType ft) {
        super(name, idFieldName, ft);
    }

    @Override
    protected Set<String> getIdSet() {
        return (Set<String>)context.req.getContext().get("BOOSTED");
    }
}
